package com.hengdu.cms.direct;

import java.io.IOException;

import com.hengdu.cms.util.RabbitMQUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class Provider {

	public static void main(String[] args) throws IOException {

		Connection connection = RabbitMQUtils.getConnection();
		Channel channel = connection.createChannel();

		// 通过通道声明交换机: 参数1: 交换机名称; 参数2: direct 路由模式
		channel.exchangeDeclare("logs_direct", "direct");

		// 发送消息
		String routingkey = "error";
		channel.basicPublish("logs_direct", routingkey, null, ("这是direct模型发布的给予 route key:[" + routingkey + "]发布的消息").getBytes());

		RabbitMQUtils.closeConnectionAndChanel(channel, connection);
	}

}
